//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package cn.dinxian.activiti.demo2.tool;

import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

public final class LambdaUtils {
  public LambdaUtils() {
  }

  public static <T, R, E extends Exception> Function<T, R> wrapFunction(FunctionWithExceptions<T, R, E> function) throws E {
    return (t) -> {
      try {
        return function.apply(t);
      } catch (Exception var3) {
        throwAsUnchecked(var3);
        return null;
      }
    };
  }

  public static <T, U, R, E extends Exception> BiFunction<T, U, R> wrapBiFunction(BiFunctionWithExceptions<T, U, R, E> biFunction) throws E {
    return (t, u) -> {
      try {
        return biFunction.apply(t, u);
      } catch (Exception var4) {
        throwAsUnchecked(var4);
        return null;
      }
    };
  }

  public static <T, E extends Exception> Consumer<T> wrapConsumer(ConsumerWithExceptions<T, E> consumer) throws E {
    return (t) -> {
      try {
        consumer.accept(t);
      } catch (Exception var3) {
        throwAsUnchecked(var3);
      }

    };
  }

  public static <T, U, E extends Exception> BiConsumer<T, U> wrapBiConsumer(BiConsumerWithExceptions<T, U, E> biConsumer) throws E {
    return (t, u) -> {
      try {
        biConsumer.accept(t, u);
      } catch (Exception var4) {
        throwAsUnchecked(var4);
      }

    };
  }

  public static <T, E extends Exception> Supplier<T> wrapSupplier(SupplierWithExceptions<T, E> function) throws E {
    return () -> {
      try {
        return function.get();
      } catch (Exception var2) {
        throwAsUnchecked(var2);
        return null;
      }
    };
  }

  public static <T, E extends Exception> Predicate<T> wrapPredicate(PredicateWithExceptions<T, E> predicate) throws E {
    return (t) -> {
      try {
        return predicate.test(t);
      } catch (Exception var3) {
        throwAsUnchecked(var3);
        return false;
      }
    };
  }

  public static <T, U, E extends Exception> BiPredicate<T, U> wrapBiPredicate(BiPredicateWithExceptions<T, U, E> predicate) throws E {
    return (t, u) -> {
      try {
        return predicate.test(t, u);
      } catch (Exception var4) {
        throwAsUnchecked(var4);
        return false;
      }
    };
  }

  public static <E extends Exception> void wrapRunnable(RunnableWithExceptions<E> runnable) throws E {
    try {
      runnable.run();
    } catch (Exception var2) {
      throwAsUnchecked(var2);
    }

  }

  public static <R, E extends Exception> R uncheck(SupplierWithExceptions<R, E> supplier) {
    try {
      return supplier.get();
    } catch (Exception var2) {
      throwAsUnchecked(var2);
      return null;
    }
  }

  public static <E extends Exception> void uncheck(RunnableWithExceptions<E> runnable) {
    try {
      runnable.run();
    } catch (Exception var2) {
      throwAsUnchecked(var2);
    }

  }

  public static <E extends Throwable> void throwAsUnchecked(Exception exception) throws E {
    
  }

  @FunctionalInterface
  public interface BiPredicateWithExceptions<T, U, E extends Exception> {
    boolean test(T t, U u) throws E;
  }

  @FunctionalInterface
  public interface PredicateWithExceptions<T, E extends Exception> {
    boolean test(T t) throws E;
  }

  @FunctionalInterface
  public interface RunnableWithExceptions<E extends Exception> {
    void run() throws E;
  }

  @FunctionalInterface
  public interface SupplierWithExceptions<T, E extends Exception> {
    T get() throws E;
  }

  @FunctionalInterface
  public interface BiFunctionWithExceptions<T, U, R, E extends Exception> {
    R apply(T t, U u) throws E;
  }

  @FunctionalInterface
  public interface FunctionWithExceptions<T, R, E extends Exception> {
    R apply(T t) throws E;
  }

  @FunctionalInterface
  public interface BiConsumerWithExceptions<T, U, E extends Exception> {
    void accept(T t, U u) throws E;
  }

  @FunctionalInterface
  public interface ConsumerWithExceptions<T, E extends Exception> {
    void accept(T t) throws E;
  }
}
